<?php
class Image_Datatype extends DatatypeBase{
	
	var $length = 11;	
	var $type = 'int';
	
	
	function view($value, $name, $extra = array()){
		return parent::image($value, $name, $extra);
	}

	function edit($value, $name, $extra = array()){
		$extra['type'] = 'file'; 
		return parent::input($value, $name, $extra);
	}
	
	function prepareDatatypeFile($fileName){
		
		$handle = F::get()->Upload($_FILES[$fileName]);
		
		$handle->file_new_name_body   = 'image_resized';
		$handle->image_resize         = true;
		$handle->image_x              = 100;
		$handle->image_ratio_y        = true;
		$handle->process( ROOT );
		if ($handle->processed) {
			echo 'image resized';
			$handle->clean();
		} else {
			echo 'error : ' . $handle->error;
		}
		
		
		
		echo('<pre>');
		var_dump($handle->uploaded);
		echo('</pre>');
		die;
	}
	
}


?>
